<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Pagination
 *
 * @author BLIND KNIGHT
 */
class Pagination {

    public function generatePagination($paginator) {
        $paginatorString = '<div class="pagination">';

        $pageSelect = '<select id="page">';
        for ($i = 1; $i <= $paginator->total_pages; $i++) {
            $option = '<option value="' . $i . '">' . $i . '</option>';
            $pageSelect .= $option;
        }
        $pageSelect .= '</select>';

        $firstPage = '<a class="btn" onclick="$(\'#page\').val(1); form.submit()"><i class="fa fa-angle-double-left"></i></a>';
        $beforePage = '<a class="btn" onclick="$(\'#page\').val(' . $paginator->before . ')"><i class="fa fa-angle-left"></i></a>';
        $nextPage = '<a class="btn" onclick="$(\'#page\').val(' . $paginator->next . ')"><i class="fa fa-angle-right"></i></a>';
        $lastPage = '<a class="btn" onclick="$(\'#page\').val(' . $paginator->last . ')"><i class="fa fa-angle-double-right"></i></a>';

        $paginatorString .= $firstPage . $beforePage;
        $paginatorString .= ' Page ' . $pageSelect . ' of ' . $paginator->total_pages;
        $paginatorString .= $nextPage . $lastPage;

        return $paginatorString;
    }

}
